cmake_minimum_required(VERSION 3.0)
project(JETSONTEST)
find_package(CUDA REQUIRED)
enable_language(CUDA)

include_directories(${CUDA_INCLUDES} ./ ./include ./include/libjpeg-8b  /usr/include/libdrm)

aux_source_directory(./ TEST)
aux_source_directory(./test DEMO)
aux_source_directory(./common/classes COMMON)
add_compile_options(-g  -fpermissive -std=gnu++1y) 
link_directories(/usr/lib/aarch64-linux-gnu/tegra /lib/aarch64-linux-gnu /usr/local/lib /usr/lib)
link_directories(/usr/local/ffmpeg/lib)
include_directories(/usr/local/ffmpeg/include)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS} 
                    ${CUDA_INCLUDE_DIRS}
                    ${TensorRT_INCLUDE_DIRS}
                    )                   
# TensorRT
set(TensorRT_INCLUDE_DIRS /usr/include/aarch64-linux-gnu)
set(TensorRT_LIBRARIES /usr/lib/aarch64-linux-gnu)
link_directories(   ${CUDA_LIBRARIES}
                    ${CUDA_LIB_DIR}
                    ${TensorRT_LIBRARIES})     
set(FFMPEG_LIBS avformat avcodec avutil swresample swscale vpx x264 x265 fdk-aac mp3lame opus) 
set(EXECUTABLE_OUTPUT_PATH ./)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ./)
set(CMAKE_BUILD_TYPE Debug)
add_library(JetsonEnc SHARED ${TEST} ${COMMON})
target_link_libraries(JetsonEnc ${CUDA_LIBRARIES} pthread v4l2 EGL GLESv2 X11 nvbufsurface nvbufsurftransform nvjpeg nvosd drm cuda)

add_executable(demo ${DEMO})
target_link_libraries(demo JetsonEnc ${OpenCV_LIBS} ${FFMPEG_LIBS} nvinfer pthread nvinfer_plugin) 
